package com.zdf.license.core.model;

import de.schlichtherle.license.LicenseContent;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * <p>License证书验证结果对象</p>
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LicenseResult {

    /** 检验结果 */
    private Boolean result;
    /** 附加信息 */
    private String message;
    /** 证书内容 */
    private LicenseContent content;
    /** 检验失败错误 */
    private Exception exception;

    public static LicenseResult success(LicenseContent content){
        return new LicenseResult(true, null, content, null);
    }

    public static LicenseResult success(String message, LicenseContent content){
        return new LicenseResult(true, message, content, null);
    }

    public static LicenseResult error(Exception exception){
        return new LicenseResult(false, null, null, exception);
    }

    public static LicenseResult error(String message, Exception exception){
        return new LicenseResult(false, message, null, exception);
    }
}
